#import "CinemasData.h"
#import "Cinema.h"

@interface CinemasData()

@property(readwrite) NSArray* allCinemas;

@end
@implementation CinemasData

+(instancetype)alloc {
    return [CinemasData sharedCinemasData];
}

-(id)copy {
    return [CinemasData sharedCinemasData];
}

+(instancetype)sharedCinemasData {
    static CinemasData* instance = nil;
    if (!instance) {
        instance = [[super alloc] init];
    }
    return instance;
}

-(NSArray *)allCinemas {
    if (!_allCinemas) {
        Cinema* arena = [[Cinema alloc] initWithName:@"Arena" andWorkingTime:@"09-23"andImage:@"arena.png"];
        Cinema* imax = [[Cinema alloc] initWithName:@"IMAX" andWorkingTime:@"09-21"andImage:@"imax.jpg"];
        Cinema* cinemaCity = [[Cinema alloc] initWithName:@"CinemaCity" andWorkingTime:@"09-24"andImage:@"city.jpg"];
        
        Movie* expendables = [[Movie alloc] initWithDuration:3 andTitle:@"Expendables"andImage:@"Expendables.jpg"];
        
        Movie* oneHourPassed = [[Movie alloc] initWithDuration:1 andTitle:@"One Hour Passed" andImage:@"oneHourPassed.jpg"];
        
        Movie* iceAge = [[Movie alloc] initWithDuration:2 andTitle:@"iceAge"andImage:@"iceAge.jpg"];
        
        [arena addMovie:expendables];
        [imax addMovie:oneHourPassed];
        [cinemaCity addMovie:iceAge];
        [cinemaCity addMovie: oneHourPassed];
        [arena addMovie:iceAge];

        _allCinemas = [NSArray arrayWithObjects:arena,cinemaCity,imax, nil];
    }
    return _allCinemas;
}



@end
